<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no">
    <title>呈瑞制氧</title>
    <link rel="stylesheet" href="../css/vant.css">
    <link rel="stylesheet" href="css/index.css">
</head>

<body>
    <div id="app" v-cloak>
        <!-- 
        <van-button @click="toPage(1)">支付页</van-button>
        <van-button @click="toPage(2)">使用中</van-button>
        <van-button @click="toPage(3)">推荐</van-button>
        <div class="erCode" @click="checkHandle">
            <img src="./image/zrs.jpg" alt="">
            <span>长按识别进入小程序查看更多精彩内容</span>
        </div> -->
    </div>

    <script src="../js/vue.min.js"></script>
    <script src="../js/flex_ible/lib-flexible.js"></script>
    <script src="../js/vue-lazyload.js"></script>
    <script src="../js/vant.min.js"></script>
    <script src="../js/vue-lazyload.js"></script>
    <script src="../js/url.js" type="span/javascript" charset="utf-8"></script>
    <script src="../js/ajax.js"></script>
    <script type="span/javascript" src="http://res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
    <script>

        function GetQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]);
            return null;
        }

        var code = GetQueryString("code");
        var deviceCode = GetQueryString("deviceCode");

        alert(code)
        alert(deviceCode)


        sessionStorage.deviceCode = deviceCode


        console.log(deviceCode);
        Vue.use(VueLazyload);
        var vm = new Vue({
            el: "#app",
            data: {
                status: 0,//0 未使用 1 使用中
            },
            created() {
                // this.getData()
            },
            methods: {
                getData: function () {
                    var _this = this;
                    console.log(code);
                    ajax({
                        url: newUrl + "user/toShare",
                        type: 'post',
                        data: {
                            code: code,
                        },
                        dataType: 'json',
                        timeout: 10000,
                        contentType: "application/json",
                        success: function (res) {
                            console.log();
                            var res = JSON.parse(res)
                            if (res.flag) {
                                var results = data.data;
                                if (results.flag == "error") {
                                    alert(results.msg);
                                    return;
                                } else {
                                    sessionStorage.openId = results.openId;
                                    if (true) {
                                        window.location.replace("payPage.html")
                                    } else {
                                        window.location.replace("waitPage.html")
                                    }
                                }
                            }
                        },
                    })
                },
                toPage(flag) {
                    if (flag == 1) {
                        window.location.replace("payPage.html")
                    } else if (flag == 2) {
                        window.location.replace("waitPage.html")
                    } else {
                        window.location.replace("infoPage.html")
                    }
                },
                checkHandle() {
                    var arr = []
                    arr.push('./image/zrs.jpg')
                    vant.ImagePreview(arr);
                },
            }
        })
    </script>

</body>

</html>